package br.com.localcar;

import br.com.controller.StatusSistemaManager;
import br.com.model.StatusSistema;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class LocalCar extends Activity {
	private StatusSistema status;
	private StatusSistemaManager statusManager;
	private Button btIncAlt, btCons;
	private TextView vwLatLon;
	private class BtInc implements OnClickListener{
		public void onClick(View v) {
			status.setLatcar(status.getLatcar()+1);
			if (status.get_id() == 0)
				statusManager.InsertStatusSistema(status);
			else
				statusManager.UpdateStatusSistema(status);
		}
	}
	private class BtCons implements OnClickListener{
		public void onClick(View v) {
			status = statusManager.getStatusSistema();
			vwLatLon.setText(Double.toString(status.getLatcar()));	
		}
	}
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		btIncAlt = (Button)findViewById(R.id.btIncAlt);
		btCons = (Button)findViewById(R.id.btConsulta);
		vwLatLon = (TextView)findViewById(R.id.tvRes);
		status = new StatusSistema();
		statusManager = new StatusSistemaManager(getApplicationContext());
		btIncAlt.setOnClickListener(new BtInc());
		btCons.setOnClickListener(new BtCons());
	}
}